package com.studentmanage.manage_score.controller;

import com.studentmanage.api.score.ScoreControllerApi;
import com.studentmanage.framework.domain.base.Score;
import com.studentmanage.framework.domain.base.ScoreExt;
import com.studentmanage.framework.domain.base.ScoreExt2;
import com.studentmanage.framework.domain.base.request.ScoreQueryRequest;
import com.studentmanage.framework.domain.common.response.QueryResult;
import com.studentmanage.framework.domain.common.response.ResponseResult;
import com.studentmanage.manage_score.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/score")
public class ScoreController implements ScoreControllerApi {
    @Autowired
    private ScoreService scoreService;

    @Override
    @PostMapping("/add")
    public ResponseResult addCourse(@RequestBody Score score) {
        return scoreService.addCourse(score);
    }

    @Override
    @GetMapping("/list/student/{studentId}/{page}/{size}")
    public QueryResult<ScoreExt> findScoreStudentList(@PathVariable("studentId") String studentId, @PathVariable("page")int page, @PathVariable("size")int size, ScoreQueryRequest scoreQueryRequest) {
        return scoreService.findScoreStudentList(studentId,page,size,scoreQueryRequest);
    }

    @Override
    @GetMapping("/list/course/{courseId}/{page}/{size}")
    public QueryResult<ScoreExt2> findScoreCourseList(@PathVariable("courseId") String courseId, @PathVariable("page")int page, @PathVariable("size")int size, ScoreQueryRequest scoreQueryRequest) {
        return scoreService.findScoreCourseList(courseId,page,size,scoreQueryRequest);
    }

    @Override
    @GetMapping("/list/excl/{id}")
    public QueryResult<ScoreExt> findScoreExclList(@PathVariable("id") String studentId) {
        return scoreService.findScoreExclList(studentId);
    }

    @Override
    @PostMapping("/edit")
    public ResponseResult editScore(@RequestBody Score score) {
        return scoreService.editScore(score);
    }

    @Override
    @DeleteMapping("/delete")
    public ResponseResult deleteScore(@RequestBody Score score) {
        return scoreService.deleteScore(score);
    }
}
